#ifndef	__AD5272_50_h__
#define	__AD5272_50_h__

#include "stdint.h"
#include <stdbool.h>
#include <integer.h>
#include <IOConfig.h>

#define DEVICE_ADDRESS_VDDIO	0x58			
#define DEVICE_ADDRESS_VDD	    0x5E	
#define DEVICE_ADDRESS_DVDD     0x5C
//#define DEVICE_ADDRESS_M5	0x5C			

#define COMMAND_NOP_INDEX					0x00
#define COMMAND_WRITE_RDAC_INDEX			0x01
#define COMMAND_READ_RDAC_INDEX				0x02
#define COMMAND_STORE_RDAC_SETTNG_INDEX		0x03
#define COMMAND_REFRESH_RDAC_INDEX			0x04
#define COMMAND_READ_OTP_CONTENT_INDEX		0x05
#define COMMAND_READ_OTP_INDEX				0x06
#define COMMAND_WRITE_CONTROL_INDEX			0x07
#define COMMAND_READ_CONTROL_INDEX			0x08
#define COMMAND_SHUTDOWN_INDEX				0x09

//-------------------------------------------------------------------------
//#define New_2KS_2023  //--新版2KS-2023,接口与佳智彩相同

//#ifdef New_2KS_2023		 //--新版2KS-2023,接口与佳智彩相同
//#define AD5272_50_PIN_SCL  GPIO_PIN_4
//#define AD5272_50_PIN_SDA  GPIO_PIN_3						
//#define GPIO_SDA                                   GPIOG
//#define GPIO_SCL                                   GPIOG
//#else						 
////----旧版2KS----
//#define AD5272_50_PIN_SCL  GPIO_PIN_4
//#define AD5272_50_PIN_SDA  GPIO_PIN_6	
//#define GPIO_SDA                                   GPIOA
//#define GPIO_SCL                                   GPIOA

//#endif

//------------------------------------------------------------
//#define AD5272_50_TPSCL_L HAL_GPIO_WritePin(GPIO_SCL, AD5272_50_PIN_SCL,GPIO_PIN_RESET)  //SCL
//#define AD5272_50_TPSCL_H HAL_GPIO_WritePin(GPIO_SCL, AD5272_50_PIN_SCL,GPIO_PIN_SET)
//#define AD5272_50_TPSDA_L HAL_GPIO_WritePin(GPIO_SDA, AD5272_50_PIN_SDA,GPIO_PIN_RESET)  //SDA
//#define AD5272_50_TPSDA_H HAL_GPIO_WritePin(GPIO_SDA, AD5272_50_PIN_SDA,GPIO_PIN_SET)

void AD5272_50_TPSCL_L(void);
void AD5272_50_TPSCL_H(void);
void AD5272_50_TPSDA_L(void);
void AD5272_50_TPSDA_H(void);

void AD5272_50_GPIO_Config(void);
void AD5272_50_I2CSDASetInput(void);
void AD5272_50_I2CSDASetOutput(void);
void AD5272_50_I2CStart(void);
void AD5272_50_I2CStop(void);
bool AD5272_50_I2CSendByte(BYTE ucData);
BYTE AD5272_50_I2CReciveByte(bool bAck);
bool AD5272_50_I2CSend(BYTE ucDeviceAddr, BYTE ucIndex, u16 RDACValue);
bool AD5272_50_I2CReceive(BYTE ucDeviceAddr, BYTE ucIndex, BYTE* pucData, unsigned int unDataLength);

unsigned int AD5272_50_BUS_VOLTAGE(void);
void VDD_AD5272_50_Init(u16 uvol);  
void VDDIO_AD5272_50_Init(u16 uvol);
void DVDD_AD5272_50_Init(u16 uvol);
void DelayMs(u16 x);
//-----------------------------------------------------------------------
#endif
